<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="vtc" uri="/vtc-core-tags"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<script src="<s:url value="/js/ejs/Grid/GridE.js"/>" type="text/javascript"> </script>
<link href="<s:url value="/js/ejs/Styles/vtc.css"/>" rel="stylesheet" type="text/css" />

<script type="text/javascript">

$(document).ready(function() {

	$("#level2PlanningForm").validate({
		rules : {
			"level2Planning.remarks" : {
				maxlength : 1000
			}
		}
	});
});

function clickBut(action) {
	switch (action) {
	case "endorse":
		$("#level2PlanningForm").attr("action", "endorsement!endorseLevel2.action");
		break;
	case "cancel":
		$("#level2PlanningForm").attr("action", "endorsement!clear.action");
		break;
	case "filter":
		//var programmeCode = $("#programmeCode");
		//alert(programmeCode);
		$("#level2PlanningForm").attr("action", "plan-second!input.action");
		break;
	case "reset":
		$("#programmeCode").attr("value", "");
		return;
	}
	$("#level2PlanningForm").submit();
}

function toViewDiscipline(discipline,level2PlanningId,categoryNodeId){
	//alert(discipline+","+level2PlanningId+","+categoryNodeId);
	window.location.href = "endorsement!viewLevel2Detail.action?no-decorate&level2Planning.id="+level2PlanningId+"&isEndorsed=true&categoryNodeId="+categoryNodeId;
	//window.location = "plansecond!getViewByDiscipline?disciplineType="+discipline;
}
</script>
<div class="content">
	<!-- InstanceBeginEditable name="content" -->
			  <s:actionerror/>
	  <s:fielderror id="fielderror" />
	  <s:actionmessage/> 
	<label  id="errorMessage" style="color: red;"></label>
	<div class="pageTitle" >2nd Level Planning</div>
	<form id="level2PlanningForm" name="level2PlanningForm" method="post">
	<s:hidden name="level2Planning.id" id="level2Planning.id" value="%{level2Planning.id}"/>
	<s:hidden name="planningId" id="planningId" value="%{level2Planning.planning.id}"/>
	<table border="0" cellspacing="0" cellpadding="0" >
		<tr>
			<td style="vertical-align: top "><div class="form2" >
					<table border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td class="sep"><img src="../images/spacer.gif"
								style="width: 180px;" />
							</td>
							<td class="sep sep2"><img src="../images/spacer.gif" />
							</td>

						</tr>
						<tr>
							<td><label class="fLabel">Planning Exercise</label>
								<div class="fField">
									<s:hidden name="level2Planning.planningExercise" id="level2Planning.planningExercise" value="%{level2Planning.planningExercise}"/>
									<select class="inputSelect" id="" name="planningExerciseTemp" style="width: 180px;">
										<option value="level2Planning.planningExercise" selected="selected">
										<script>
										var year = "<s:property value='level2Planning.planningExercise'/>";
										if(year!=null && year!='' && year!=0){
											var toYear = year.toString().substring(2);
											document.write(year+"/"+(parseFloat(toYear) + 1));
										}
										</script>
										</option>
									</select>
								</div>
							</td>
							<td><label class="fLabel">1st Level Planning Status</label>
								<div class="fField">
									<s:textfield id="level1Status" name="level1Status" cssClass="inputText" cssStyle="width:300px" readonly="true"></s:textfield>

								</div>
							</td>
						</tr>
						<tr>
							<td colspan="2"><label class="fLabel">Remarks</label>
								<div class="fField">
								<s:textarea id="remarks" name="level2Planning.remarks" cssClass="inputTextarea" cssStyle="width: 500px; height: 100px;" ></s:textarea>
								</div>
							</td>
						</tr>

						<tr>
							<td><label class="fLabel">Status</label>
								<div class="fField">
								<s:textfield id="status" name="status" value="%{level2Planning.planning.status.label}" cssClass="inputText" cssStyle="width:150px" readonly="true"></s:textfield>
								</div>
							</td>
						</tr>
					</table>
					<div class="btnSet btnSetTypeA">

						<div class="left">
						<security:authorize access="hasRole('ENDORSE_2ND_LEVEL')">
							<div class="button">
								<div class="left">
									<div class="right">
										<input class="inputButton" type="button" id="" name=""
											value="Endorse" onclick="clickBut('endorse')" />
									</div>
								</div>
							</div>
							</security:authorize>
							<div class="button">

								<div class="left">
									<div class="right">
										<input class="inputButton" type="button" id="" name=""
											value="Cancel" onclick="clickBut('cancel')" />
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</td>

			<td style="width: 5px;">&nbsp;</td>
			<td style="vertical-align: top; width: 400px; border: 0px solid red;">
			<div
					class="form1" style="margin-bottom: 0px !important;">
					<table border="0" cellspacing="0" cellpadding="0" bordercolor="red">
						<tr>
							<td class="sep"><img src="../images/spacer.gif"
								style="width: 125px;" />
							</td>
							<td class="sep"><img src="../images/spacer.gif"
								style="width: 140px;" />
							</td>
							<td class="sep sep2"><img src="../images/spacer.gif" />
							</td>
						</tr>
						<tr>

							<td><label class="fLabel">Programme Code </label>
							</td>
							<td><div class="fField">
							<s:textfield id="programmeCode" name="programmeCode" cssClass="inputText" cssStyle="width:150px"></s:textfield>
							
								</div>
							</td>
							<td><div class="button sbtn">
									<div class="left">
										<div class="right">
											<input class="inputButton" type="button" id="" name=""
												value="Filter"
												onclick="clickBut('filter')" />

										</div>
									</div>
								</div>
								<div class="button sbtn">
									<div class="left">
										<div class="right">
											<input class="inputButton" type="button" id="" name=""
												value="Reset"
												onclick="clickBut('reset')" />
										</div>
									</div>

								</div>
							</td>
						</tr>
						<tr>
					<td colspan="3" width="100%" >
						<div style="height:100%;" >
 <div style="height:90%;">
          <bdo Debug='3' 
               Data_Url="endorsement!loadLevel2Tree.action?no-decorate&level2Planning.id=<s:property value='level2Planning.id'/>&level1Status=<s:property value='level1Status'/>&programmeCode=<s:property value='programmeCode'/>"
               >
          </bdo>	
           </div></div>						
							</td>
						</tr>
					</table>
				</div>
							</td>
		</tr>
	</table>
	</form>
	<!-- InstanceEndEditable -->
</div>
